<?php

namespace app\modules\merchant\forms\category;

use app\common\forms\BaseForm;

class GoodsCategoryForm extends BaseForm{

    public $merchant_id;
    public $cat_id;
    public $cat_name;
    public $sort;
    public $is_show;

    public function scenarios()
    {
        return [
            'create'=>[
                'merchant_id','cat_name','sort','is_show'
            ],
            'update'=>[
                'cat_id','merchant_id','cat_name','sort','is_show'
            ],
        ];
    }

    public function rules()
    {
        return [
            ['merchant_id','default','on'=>['create','update'],'value'=>\Yii::$app->getModule("merchant")->get("user")->getId()],
            ['cat_id','required','on'=>['update'],'message'=>\Yii::t("app","ID不能为空")],
            ['cat_name','required','on'=>['create','update'],'message'=>\Yii::t("app","名称不能为空")],
            ['sort','integer','skipOnEmpty'=>false,'on'=>['create','update'],'message'=>\Yii::t("app","排序错误")],
            ['is_show','in','range'=>[1,2],'on'=>['create','update'],'skipOnEmpty'=>false,'message'=>\Yii::t("app","显示值错误")],
        ];
    }
}